const {default:request}=require("../../utils/request")

Page({
  data: {
    category:null,
    curIndex: 0,
    toView: 'guowei'
  },
  onReady(){
    this.renderCategory()
  },
  renderCategory(){
    request({
      url:"/category"
    }).then(res=>{
      console.log(res)
// 将数据放入looplist中
      this.setData({
        category:res
      })
    })
  },
  switchTab(e){
    //将获取到的item的id和数组的下表值设为当前的id和下标
    this.setData({
      toView: e.target.dataset.id,
      curIndex: e.target.dataset.index
    })
  } 
})  